home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / bbs / msfilter2.lha / MSFilter2.c < prev    next >
C/C++ Source or Header  |  1997-07-19  |  19KB  |  550 lines

  1. #include <exec/types.h>
  2. #include <dos/dos.h>
  3. #include <dos/dosextens.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "MSFilter.h"
  8.  
  9. struct pkt_hdr my_ibm_pkt;
  10. struct pkt_hdr my_amy_pkt;
  11.  
  12. struct pak_msg_hdr my_ibm_msg;
  13. struct pak_msg_hdr my_amy_msg;
  14.  
  15. UBYTE  msg_date[20];
  16. UBYTE  msg_to[36];
  17. UBYTE  msg_from[36];
  18. UBYTE  msg_subject[72];
  19.  
  20. UBYTE pkt_name[80];
  21. UBYTE pkt_path[80];
  22. UBYTE log_file[128];
  23. UBYTE file_name[128];
  24. UBYTE t_file_name[128];
  25. UBYTE config_file[128];
  26.  
  27. FILE *in = NULL;
  28. FILE *out = NULL;
  29. FILE *log = NULL;
  30.  
  31. #define MC 1001
  32.  
  33. /* #define DEBUG 0x01 */
  34.  
  35. UBYTE filter_from[MC][80];
  36. UBYTE filter_to[MC][80];
  37. UBYTE keep_to[MC][80];
  38. UBYTE keep_from[MC][80];
  39. UBYTE filter_subject[MC][80];
  40. UBYTE keep_subject[MC][80];
  41.  
  42. struct FileInfoBlock __aligned my_info;
  43. struct FileLock *my_lock;
  44.  
  45. char *version = "$VER: MSFilter 2.001beta (c) 1994-1997 by Doug McLean (19-Jul-1997)";
  46.  
  47. void main(int argc, char *argv[])
  48. {
  49. int numpkts = 0;
  50.         printf ("%s\n",&version[6]);
  51.         if (argc != 4)
  52.         {
  53.                 printf ("USAGE: %s Inbound: Logs: Config_File_Name\n",argv[0]);
  54.                 exit (10);
  55.         }
  56.         sprintf (pkt_path,"%s",argv[1]);
  57.         sprintf (log_file,"%sMSFilter.log",argv[2]);
  58.         sprintf (config_file,"%s",argv[3]);
  59.         if ((log=fopen(log_file,"ab"))==NULL)
  60.         {
  61.                 printf ("Cannot open %s for log\n",log_file);
  62.                 exit (12);
  63.         }
  64.         if (read_config()==0)
  65.         {
  66.                 printf ("Cannot open config file %s\n",config_file);
  67.                 fclose (log);
  68.                 exit (13);
  69.         }
  70.         if ((my_lock = (struct FileLock *)Lock(pkt_path,ACCESS_READ))==NULL)
  71.         {
  72.                 printf ("Cannot get lock on %s\n",pkt_path);
  73.                 fclose (log);
  74.                 exit (11);
  75.         }
  76.         Examine (my_lock,&my_info);
  77.         while (ExNext(my_lock,&my_info))
  78.         {
  79.            if (my_info.fib_DirEntryType >= 0) continue;
  80.            if (strlen(my_info.fib_FileName)!=12)continue;
  81.            if (stricmp(&my_info.fib_FileName[8],".pkt")) continue;
  82.            sprintf (pkt_name,"%s",my_info.fib_FileName);
  83.            sprintf (file_name,"%s%s",pkt_path,pkt_name);
  84.            numpkts++;
  85.            parse_pkt();
  86.         }
  87.         UnLock (my_lock);
  88.         printf ("**** PROCESSED %d PACKETS THIS SESSION ****\n",numpkts);
  89.         fprintf (log,"**** PROCESSED %d PACKETS THIS SESSION ****\n",numpkts);
  90.         fclose (log);
  91.         exit (0);
  92. }
  93.  
  94. read_config()
  95. {
  96. FILE *cfg = NULL;
  97. char inbuff[128];
  98. int i_f = 0;
  99. int i_t = 0;
  100. int i_kt = 0;
  101. int i_kf = 0;
  102. int i_s = 0;
  103. int i_sk = 0;
  104.         fprintf (log,"\n------------------------------------------------------------\n");
  105.         fprintf (log,"%s\nCurrent configuration:\n",&version[6]);
  106.         if ((cfg=fopen(config_file,"rb"))==NULL) return (0);
  107.         while (fgets(inbuff,80,cfg))
  108.         {
  109.                 strip_n(inbuff);
  110.                 if (strlen(inbuff) < 4)
  111.                 {
  112.                         fprintf (log,"   ???????? SHORT LINE: %s\n",inbuff);
  113.                         continue;
  114.                 }
  115.                 inbuff[79]=0x00;
  116.                 strlwr(inbuff);
  117.                 switch (inbuff[0])
  118.                 {
  119.                     case ';': /* comment line */
  120.                         fprintf (log,"   ******** %s\n",&inbuff[1]);
  121.                         break;
  122.                     case '<': /* filter from */
  123.                         if (i_f > (MC-2))
  124.                         {
  125.                            fprintf (log,"   WARNING: From buffer full, [%s] not filtered\n",&inbuff[1]);
  126.                         }
  127.                         else
  128.                         {
  129.                            sprintf (filter_from[i_f],"%s",&inbuff[1]);
  130.                            fprintf (log,"   [ < ] Filter From    [%s*]\n",filter_from[i_f]);
  131.                            i_f++;
  132.                         }
  133.                         break;
  134.                     case '>': /* filter to */
  135.                         if (i_t > (MC-2))
  136.                         {
  137.                            fprintf (log,"   WARNING: To buffer full, [%s] not filtered\n",&inbuff[1]);
  138.                         }
  139.                         else
  140.                         {
  141.                            sprintf (filter_to[i_t],"%s",&inbuff[1]);
  142.                            fprintf (log,"   [ > ] Filter To      [%s*]\n",filter_to[i_t]);
  143.                            i_t++;
  144.                         }
  145.                         break;
  146.                     case '+': /* keep to */
  147.                         if (i_kt > (MC-2))
  148.                         {
  149.                            fprintf (log,"   WARNING: Keep to buffer full, [%s] not kept\n",&inbuff[1]);
  150.                         }
  151.                         else
  152.                         {
  153.                            sprintf (keep_to[i_kt],"%s",&inbuff[1]);
  154.                            fprintf (log,"   [ + ] Keep To        [%s*]\n",keep_to[i_kt]);
  155.                            i_kt++;
  156.                         }
  157.                         break;
  158.                     case '&': /* keep from */
  159.                         if (i_kf > (MC-2))
  160.                         {
  161.                            fprintf (log,"   WARNING: Keep from buffer full, [%s] not kept\n",&inbuff[1]);
  162.                         }
  163.                         else
  164.                         {
  165.                            sprintf (keep_from[i_kf],"%s",&inbuff[1]);
  166.                            fprintf (log,"   [ & ] Keep From      [%s*]\n",keep_from[i_kf]);
  167.                            i_kf++;
  168.                         }
  169.                         break;
  170.                     case '=': /* filter subject */
  171.                         if (i_s > (MC-2))
  172.                         {
  173.                            fprintf (log,"   WARNING: Subject buffer full, [%s] not filtered\n",&inbuff[1]);
  174.                         }
  175.                         else
  176.                         {
  177.                            sprintf (filter_subject[i_s],"%s",&inbuff[1]);
  178.                            fprintf (log,"   [ = ] Filter Subject [*%s*]\n",filter_subject[i_s]);
  179.                            i_s++;
  180.                         }
  181.                         break;
  182.                     case '$': /* keep subject */
  183.                         if (i_sk > (MC-2))
  184.                         {
  185.                            fprintf (log,"   WARNING: Keep subject buffer full, [%s] not kept\n",&inbuff[1]);
  186.                         }
  187.                         else
  188.                         {
  189.                            sprintf (keep_subject[i_sk],"%s",&inbuff[1]);
  190.                            fprintf (log,"   [ $ ] Keep Subject   [*%s*]\n",keep_subject[i_sk]);
  191.                            i_sk++;
  192.                         }
  193.                         break;
  194.                         
  195.                     default:
  196.                         fprintf (log,"   ???????? CONFIG ERROR: %s\n",inbuff);
  197.                         break;
  198.                 }
  199.         }
  200.         fclose (cfg);
  201.         filter_from[MC-1][0] = 0x00;
  202.         filter_to[MC-1][0] = 0x00;
  203.         keep_to[MC-1][0] = 0x00;
  204.         keep_from[MC-1][0] = 0x00;
  205.         filter_subject[MC-1][0] = 0x00;
  206.         fprintf (log,"------------------------------------------------------------\n");
  207.         return (1);
  208. }
  209.  
  210. strip_n(char *buffer)
  211. {
  212.         while (*buffer!=0x00)
  213.         {
  214.                 if (*buffer == '\n') *buffer = 0x00;
  215.                 if (*buffer == '\r') *buffer = 0x00;
  216.                 buffer++;
  217.         }
  218.         return (0);
  219. }
  220.  
  221. parse_pkt()
  222. {
  223. int num_msgs = 0;
  224. int ch;
  225. int i;
  226. int pkt_filtered = 0;
  227. int fr;
  228.         if ((in = fopen(file_name,"rb"))==NULL)
  229.         {
  230.                 printf ("Cannot open %s for input\n",file_name);
  231.                 return (0);
  232.         }
  233.         sprintf (t_file_name,"%s.msfilter",file_name);
  234.         if ((out = fopen(t_file_name,"wb"))==NULL)
  235.         {
  236.                 printf ("Cannot open %s for output\n",t_file_name);
  237.                 fprintf (log,"Cannot open %s for output\n",t_file_name);
  238.                 fclose (out);
  239.                 return (0);
  240.         }
  241.         if (fread((char *)&my_ibm_pkt,sizeof(my_ibm_pkt),1,in)!=1)
  242.         {
  243.                 fclose (in);
  244.                 printf ("Bad header for packet %s\n",file_name);
  245.                 fprintf (log,"Bad header for packet %s\n",file_name);
  246.                 return (0);
  247.         }
  248.         fwrite ((char *)&my_ibm_pkt,sizeof(my_ibm_pkt),1,out);
  249.         
  250.         pkt_ibm_to_amy(&my_ibm_pkt,&my_amy_pkt);
  251.  
  252.         print_pkt_hdr(&my_amy_pkt);
  253.         printf ("Working on packet %s\n",pkt_name);
  254.         
  255.         while (fread((char *)&my_ibm_msg,sizeof(my_ibm_msg),1,in)==1)
  256.         {
  257.             for (i = 0; i < 20; i++)
  258.             {
  259.                 ch = fgetc(in);
  260.                 if (ch==EOF) goto eop;
  261.                 msg_date[i] = ch;
  262.                 if (ch == 0x00) break;
  263.             }
  264.             for (i = 0; i < 36; i++)
  265.             {
  266.                 ch = fgetc(in);
  267.                 if (ch==EOF) goto eop;
  268.                 msg_to[i] = ch;
  269.                 if (ch == 0x00) break;
  270.             }
  271.             for (i = 0; i < 36; i++)
  272.             {
  273.                 ch = fgetc(in);
  274.                 if (ch==EOF) goto eop;
  275.                 msg_from[i] = ch;
  276.                 if (ch == 0x00) break;
  277.             }
  278.             for (i = 0; i < 72; i++)
  279.             {
  280.                 ch = fgetc(in);
  281.                 if (ch==EOF) goto eop;
  282.                 msg_subject[i] = ch;
  283.                 if (ch == 0x00) break;
  284.             }
  285.             msg_ibm_to_amy(&my_ibm_msg,&my_amy_msg);
  286.  
  287.             printf (" Message #%-5d...",num_msgs);
  288.  
  289.             if ((fr =filter_msg())==0)
  290.             {
  291.                 write_ibm_msg();
  292.                 printf ("...Ok      \n");
  293.             }
  294.             else
  295.             {
  296.                 pkt_filtered++;
  297.                 print_msg_hdr(&my_amy_msg,num_msgs,fr);
  298.                 log_filtered_msg();
  299.                 printf ("...Filtered\n\n");
  300.             }
  301.             printf ("\033[1A");
  302.             num_msgs++;
  303.         }
  304. eop:
  305.         fputc(0x00,out);fputc(0x00,out);
  306.         fclose (in);
  307.         fclose (out);
  308.         printf ("\nEnd of packet\n");
  309.         printf ("PACKET CONTAINED %d MESSAGES\n",num_msgs);
  310.         fprintf (log,"PACKET CONTAINED %d MESSAGES\n",num_msgs);
  311.         if (pkt_filtered == 0)
  312.         {
  313.                 printf ("NO MESSAGES FILTERED IN THIS PACKET\n");
  314.                 fprintf (log,"NO MESSAGES FILTERED IN THIS PACKET\n\n");
  315.                 DeleteFile (t_file_name);
  316.         }
  317.         else if (pkt_filtered != num_msgs)
  318.         {
  319.                 printf ("TOTAL OF %d MESSAGES FILTERED FROM THIS PACKET\n",pkt_filtered);
  320.                 fprintf (log,"TOTAL OF %d MESSAGES FILTERED FROM THIS PACKET\n\n",pkt_filtered);
  321.                 DeleteFile (file_name);
  322.                 Rename (t_file_name,file_name);
  323.         }
  324.         else
  325.         {
  326.                 printf ("TOTAL OF %d MESSAGES FILTERED FROM THIS PACKET\n",pkt_filtered);
  327.                 printf ("ALL MESSAGES IN PACKET WERE FILTERED. PACKET DELETED\n");
  328.                 fprintf (log,"TOTAL OF %d MESSAGES FILTERED FROM THIS PACKET\n",pkt_filtered);
  329.                 fprintf (log,"ALL MESSAGES IN PACKET WERE FILTERED. PACKET DELETED\n\n");
  330.                 DeleteFile (file_name);
  331.                 DeleteFile (t_file_name);
  332.         }
  333.         printf ("\n");
  334.         return (0);        
  335. }
  336.  
  337. filter_msg()
  338. {
  339. int i;
  340. UBYTE msg_temp[80];
  341.  
  342. /*** check keep strings first. probably keep most based on to ***/
  343.  
  344.         strcpy (msg_temp,msg_to);
  345.         strlwr (msg_temp);
  346.         i = 0;
  347. #ifdef DEBUG
  348.          printf ("** To: [%s]  Temp: [%s]\n",msg_to,msg_temp);
  349. #endif
  350.         while (keep_to[i][0]!=0x00)
  351.         {
  352.                 if (strstr(msg_temp,keep_to[i])) return (0);
  353.                 i++;
  354.         }
  355.         strcpy (msg_temp,msg_from);
  356.         strlwr (msg_temp);
  357.         i = 0;
  358. #ifdef DEBUG
  359.          printf ("** From: [%s]  Temp: [%s]\n",msg_from,msg_temp);
  360. #endif
  361.         while (keep_from[i][0]!=0x00)
  362.         {
  363.                 if (strstr(msg_temp,keep_from[i])) return (0);
  364.                 i++;
  365.         }
  366.         strcpy (msg_temp,msg_subject);
  367.         strlwr (msg_temp);
  368.         i = 0;
  369. #ifdef DEBUG
  370.          printf ("** Subject: [%s]  Temp: [%s]\n",msg_subject,msg_temp);
  371. #endif
  372.         while (keep_subject[i][0]!=0x00)
  373.         {
  374.                 if (strstr(msg_temp,keep_subject[i])) return (0);
  375.                 i++;
  376.         }
  377.  
  378. /***** check filters. probably reject more on from than subject
  379.        so check it first. if more rejects are expected due to
  380.        subject, then put that section first **********/
  381.  
  382.         strcpy (msg_temp,msg_from);
  383.         strlwr (msg_temp);
  384.         i = 0;
  385. #ifdef DEBUG
  386.          printf ("** From: [%s]  Temp: [%s]\n",msg_from,msg_temp);
  387. #endif
  388.         while (filter_from[i][0]!=0x00)
  389.         {
  390. #ifdef DEBUG
  391.           printf ("  I: %d  From: [%s]  Filter: [%s]\n",i,msg_temp,filter_from[i]);
  392. #endif
  393.                 if (strstr(msg_temp,filter_from[i])) return (1);
  394.                 i++;                
  395.         }
  396.         strcpy (msg_temp,msg_subject);
  397.         strlwr (msg_temp);
  398.         i = 0;
  399. #ifdef DEBUG
  400.          printf ("** Subject: [%s]  Temp: [%s]\n",msg_subject,msg_temp);
  401. #endif
  402.         while (filter_subject[i][0]!=0x00)
  403.         {
  404. #ifdef DEBUG
  405.           printf ("  I: %d  Subject: [%s]  Filter: [%s]\n",i,msg_temp,filter_subject[i]);
  406. #endif
  407.                 if (strstr(msg_temp,filter_subject[i])) return (3);
  408.                 i++;
  409.         }
  410.         strcpy (msg_temp,msg_to);
  411.         strlwr (msg_temp);
  412.         i = 0;
  413. #ifdef DEBUG
  414.          printf ("** To: [%s]  Temp: [%s]\n",msg_to,msg_temp);
  415. #endif
  416.         while (filter_to[i][0]!=0x00)
  417.         {
  418. #ifdef DEBUG
  419.           printf ("  I: %d  To: [%s]  Filter: [%s]\n",i,msg_temp,filter_to[i]);
  420. #endif
  421.                 if (strstr(msg_temp,filter_to[i])) return (2);
  422.                 i++;
  423.         }
  424.         return (0);
  425. }
  426.  
  427. log_filtered_msg()
  428. {
  429. int ch;
  430. int i = 0;
  431.       fprintf (log,"- - - - - - - - - - - - - - - Message Text - - - - - - - - - - - - - - - -\n");
  432.        while ((ch = fgetc(in))!=0x00)
  433.        {
  434.             if (ch==EOF) break;
  435.             if ((ch >= 32) && (ch <= 126))
  436.             {
  437.                 fputc (ch,log);
  438.                 i++;
  439.             }
  440.             else if ((ch == '\r')||(ch == '\n')) i = 80;
  441.             else
  442.             {
  443.                 fprintf (log,"[0x%x]",ch);
  444.                 i+=6;
  445.             }
  446.             if (i > 77)
  447.             {
  448.                 fputc('\n',log);
  449.                 i = 0;
  450.             }
  451.        }
  452.        fprintf (log,"- - - - - - - - - - - - - - End Message Text - - - - - - - - - - - - - - -\n");
  453.        return(0);
  454. }
  455.  
  456. write_ibm_msg()
  457. {
  458. int ch;
  459.         fwrite ((char *)&my_ibm_msg,sizeof(my_ibm_msg),1,out);
  460.         fprintf (out,"%s",msg_date);fputc(0x00,out);
  461.         fprintf (out,"%s",msg_to);fputc(0x00,out);
  462.         fprintf (out,"%s",msg_from);fputc(0x00,out);
  463.         fprintf (out,"%s",msg_subject);fputc(0x00,out);
  464.         while ((ch = fgetc(in))!=0x00)
  465.         {
  466.             if (ch==EOF) break;
  467.             fputc(ch,out);
  468.         }
  469.         fputc(0x00,out);
  470.         return (0);
  471. }
  472.  
  473. msg_ibm_to_amy(struct pak_msg_hdr *ibm,struct pak_msg_hdr *amy)
  474. {
  475.         amy->m_type = ((ibm->m_type & 0xff00) >> 8) | ((ibm->m_type & 0x00ff) << 8);
  476.         amy->m_orig_node = ((ibm->m_orig_node & 0xff00) >> 8) | ((ibm->m_orig_node & 0x00ff) << 8);
  477.         amy->m_dest_node = ((ibm->m_dest_node & 0xff00) >> 8) | ((ibm->m_dest_node & 0x00ff) << 8);
  478.         amy->m_orig_net = ((ibm->m_orig_net & 0xff00) >> 8) | ((ibm->m_orig_net & 0x00ff) << 8);
  479.         amy->m_dest_net = ((ibm->m_dest_net & 0xff00) >> 8) | ((ibm->m_dest_net & 0x00ff) << 8);
  480.         amy->m_attribute = ((ibm->m_attribute & 0xff00) >> 8) | ((ibm->m_attribute & 0x00ff) << 8);
  481.         amy->m_cost = ((ibm->m_cost & 0xff00) >> 8) | ((ibm->m_cost & 0x00ff) << 8);
  482.         return (0);
  483. }
  484.  
  485. pkt_ibm_to_amy(struct pkt_hdr *ibm,struct pkt_hdr *amy)
  486. {
  487. int i;
  488.         amy->p_orig_node = ((ibm->p_orig_node & 0xff00) >> 8) | ((ibm->p_orig_node & 0x00ff) << 8);
  489.         amy->p_dest_node = ((ibm->p_dest_node & 0xff00) >> 8) | ((ibm->p_dest_node & 0x00ff) << 8);
  490.         amy->p_year = ((ibm->p_year & 0xff00) >> 8) | ((ibm->p_year & 0x00ff) << 8);
  491.         amy->p_month = ((ibm->p_month & 0xff00) >> 8) | ((ibm->p_month & 0x00ff) << 8);
  492.         amy->p_day = ((ibm->p_day & 0xff00) >> 8) | ((ibm->p_day & 0x00ff) << 8);
  493.         amy->p_hour = ((ibm->p_hour & 0xff00) >> 8) | ((ibm->p_hour & 0x00ff) << 8);
  494.         amy->p_min = ((ibm->p_min & 0xff00) >> 8) | ((ibm->p_min & 0x00ff) << 8);
  495.         amy->p_sec = ((ibm->p_sec & 0xff00) >> 8) | ((ibm->p_sec & 0x00ff) << 8);
  496.         amy->p_baud = ((ibm->p_baud & 0xff00) >> 8) | ((ibm->p_baud & 0x00ff) << 8);
  497.         amy->p_orig_net = ((ibm->p_orig_net & 0xff00) >> 8) | ((ibm->p_orig_net & 0x00ff) << 8);
  498.         amy->p_dest_net = ((ibm->p_dest_net & 0xff00) >> 8) | ((ibm->p_dest_net & 0x00ff) << 8);
  499.         amy->p_orig_zone = ((ibm->p_orig_zone & 0xff00) >> 8) | ((ibm->p_orig_zone & 0x00ff) << 8);
  500.         amy->p_dest_zone = ((ibm->p_dest_zone & 0xff00) >> 8) | ((ibm->p_dest_zone & 0x00ff) << 8);
  501.         amy->p_type = ((ibm->p_type & 0xff00) >> 8) | ((ibm->p_type & 0x00ff) << 8);
  502.         amy->p_pcode = ibm->p_pcode;
  503.         amy->p_psernum = ibm->p_psernum;
  504.         sprintf (amy->p_password,"%s",ibm->p_password);
  505.         for (i = 0; i < 20; i++) amy->p_fill[i] = ibm->p_fill[i];
  506.         return (0);        
  507. }
  508.  
  509. print_pkt_hdr(struct pkt_hdr *pkt)
  510. {
  511. int i;
  512.         fprintf (log,"Packet Header for %s :\n",pkt_name);
  513.         fprintf (log,"  Orig Node  : %d:%d/%d\n",pkt->p_orig_zone,pkt->p_orig_net,pkt->p_orig_node);
  514.         fprintf (log,"  Dest Node  : %d:%d/%d\n",pkt->p_dest_zone,pkt->p_dest_net,pkt->p_dest_node);
  515.         fprintf (log,"  Date       : Year:%-4d   Month:%-4d Day:%-4d\n               Hour:%-4d   Min  :%-4d Sec:%-4d\n",pkt->p_year,pkt->p_month,pkt->p_day,pkt->p_hour,pkt->p_min,pkt->p_sec);
  516.         fprintf (log,"  Baud       : %d\n",pkt->p_baud);
  517.         fprintf (log,"  Type       : %d\n",pkt->p_type);
  518.         fprintf (log,"  Prod Code  : %d\n",pkt->p_pcode);
  519.         fprintf (log,"  Serial Num : %d\n",pkt->p_psernum);
  520.         fprintf (log,"  Password   : %s\n",pkt->p_password);
  521.         fprintf (log,"  Filler     :");
  522.         for (i = 0; i < 10; i++) fprintf (log," 0x%-2x",pkt->p_fill[i]);
  523.         fprintf (log,"\n              ");
  524.         for (i = 10; i < 20; i++) fprintf (log," 0x%-2x",pkt->p_fill[i]);
  525.         fprintf (log,"\n");
  526.         return (0);
  527. }
  528.  
  529. print_msg_hdr(struct pak_msg_hdr *msg,int num_msgs, int fr)
  530. {
  531. UBYTE *reasons[] = {
  532.   "OOPS, NOT FILTERED",
  533.   "WHO IT IS FROM",
  534.   "WHO IT IS TO",
  535.   "THE SUBJECT"
  536. };
  537.         fprintf (log,"  Header For Message #%d\n",num_msgs);
  538.         fprintf (log,"     FILTERED BECAUSE OF %s\n",reasons[fr]);
  539.         fprintf (log,"     Type      : %d\n",msg->m_type);
  540.         fprintf (log,"     Orig Node : %d/%d\n",msg->m_orig_net,msg->m_orig_node);
  541.         fprintf (log,"     Dest Node : %d/%d\n",msg->m_dest_net,msg->m_dest_net);
  542.         fprintf (log,"     Flags     : 0x%x\n",msg->m_attribute);
  543.         fprintf (log,"     Cost      : %d\n",msg->m_cost);
  544.         fprintf (log,"     Date      : %s\n",msg_date);
  545.         fprintf (log,"     To        : %s\n",msg_to);
  546.         fprintf (log,"     From      : %s\n",msg_from);
  547.         fprintf (log,"     Subject   : %s\n",msg_subject);
  548.         return (0);
  549. }
  550.